#ifndef _CNF_SVR_CLIENT_H_
#define _CNF_SVR_CLIENT_H_

#include <string>
#include <list>

#include <log4cxx/logger.h>

#include "SocketConnPool.h"

using std::string;
using std::list;

using namespace log4cxx;

struct NS_CNF {
        string ip;
        unsigned short port;
        int status;
        int thread_num;
        int socket_conn_timeout;
        int socket_idle_timeout;
        int socket_send_timeout;
        int socket_recv_timeout;
        int socket_max_request_size;
        int socket_max_response_size;
	int client_conn_pool_size;
        string log_cnf_file;
        string root_data_path;
        time_t create_time;
};

struct MDS_CNF {
        string ip;
        unsigned short port;
        int id;
        int weight;
        int status;
        int thread_num;
        int socket_conn_timeout;
        int socket_idle_timeout;
        int socket_send_timeout;
        int socket_recv_timeout;
        int socket_max_request_size;
        int socket_max_response_size;
        int client_conn_pool_size;
        string log_cnf_file;
        string root_data_path;
        time_t create_time;
};

struct DS_CNF {
        string ip;
        unsigned short port;
        int id;
        int mds_id;
        int read_weight;
        int write_weight;
        int status;
        int thread_num;
        int socket_conn_timeout;
        int socket_idle_timeout;
        int socket_send_timeout;
        int socket_recv_timeout;
        int socket_max_request_size;
        int socket_max_response_size;
        int client_conn_pool_size;
        string log_cnf_file;
        string root_data_path;
        time_t create_time;
};

class CnfSvrClient {
	public:
		int init(const char * svr_ip, const unsigned svr_port, const int conn_pool_size, const int conn_timeout, \
				const int send_timeout, const int recv_timeout, const int max_response_size);

		int get_all_cnf(NS_CNF & ns, list<MDS_CNF> & l_mds, list<DS_CNF> & l_ds);
		
		int get_ns_cnf(NS_CNF & ns);
		int get_all_mds_cnf(list<MDS_CNF> & l_mds);
		int get_all_ds_cnf(list<DS_CNF> & l_ds);

	private:
		SocketConnPool _pool;
		string _svr_ip;
		unsigned short _svr_port;
		int _conn_pool_size; 
		int _conn_timeout;
		static LoggerPtr _logger;
		int _send_timeout;
		int _recv_timeout;
		int _max_response_size;
};


#endif
